import request from '@/utils/request';

/**
 * 工资发放列表
 */
export async function pageJobSalary(params) {
  const res = await request.post('/job_salary/getList', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 审核工资发放到用户账户
 */
export async function payToAccount(params) {
  const res = await request.post('/job_salary/pay', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 工资审核不通过
 */
export async function rejectJobSalary(params) {
  const res = await request.post('/job_salary/reject', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 预支工资申请列表
 */
export async function pageAdvanceWageList(params) {
  params.tenant_id = JSON.stringify(params.tenant_id);
  const res = await request.post('/advance_wage/getList', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 预支工资申请列表
 */
export async function judgeAdvanceWage(params) {
  const res = await request.post('/advance_wage/setStatus', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 预支工资申请列表
 */
export async function exportAdvanceWageList(params) {
  params.tenant_id = JSON.stringify(params.tenant_id);
  const res = await request.post('/advance_wage/export', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 提现申请列表
 */
export async function pageWithdraw(params) {
  if (params.startDate === null) params.startDate = '';
  if (params.endDate === null) params.endDate = '';
  if (params.startJudgeDate === null) params.startJudgeDate = '';
  if (params.endJudgeDate === null) params.endJudgeDate = '';
  params.tenant_id = JSON.stringify(params.tenant_id);
  const res = await request.post('/student_withdraw/getList', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 导出提现列表
 */
export async function exportWithdrawList(params) {
  if (params.startDate === null) params.startDate = '';
  if (params.endDate === null) params.endDate = '';
  if (params.startJudgeDate === null) params.startJudgeDate = '';
  if (params.endJudgeDate === null) params.endJudgeDate = '';
  params.tenant_id = JSON.stringify(params.tenant_id);
  const res = await request.post('/student_withdraw/export', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 导出提现列表
 */
export async function payWithdraw(params) {
  const res = await request.post('/student_withdraw/setStatus', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 自动还款列表
 */
export async function pageAutoRepay(params) {
  const res = await request.post('/bill_auto_repay/getList', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 自动还款列表
 */
export async function passAutoRepay(params) {
  const res = await request.post('/bill_auto_repay/setStatus', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 推荐奖励列表
 */
export async function pageBounsList(params) {
  params.tenant_id = JSON.stringify(params.tenant_id);
  const res = await request.post('/bouns/getList', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 审核推荐奖励
 */
export async function payBouns(params) {
  const res = await request.post('/bouns/setStatus', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 导出推荐奖励列表
 */
export async function exportBounsList(params) {
  const res = await request.post('/bouns/exportExcel', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 审核推荐奖励
 */
export async function pageCreditToCash(params) {
  const res = await request.post('/member_credit_detail/getJudgeList', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 积分兑换审核
 */
export async function judgeCreditToCash(params) {
  const res = await request.post('/member_credit_detail/judge', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 积分兑换审核
 */
export async function pageWatingPay(params) {
  const res = await request.post('/job_salary/getWatingPayList', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 积分兑换审核
 */
export async function pageBalanceReport(params) {
  const res = await request.post('/report_balance/getList', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 支付记录
 */
export async function pagePayRecord(params) {
  params.tenant_id = JSON.stringify(params.tenant_id);
  const res = await request.post('/pay_record/getList', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 工资发放记录导出
 */
export async function exportJobSalary(params) {
  if (params.startDate === null) params.startDate = '';
  if (params.endDate === null) params.endDate = '';
  if (params.createTime === null) params.createTime = '';
  if (params.judgeTime === null) params.judgeTime = '';
  if (params.belongs_date === null) params.belongs_date = '';
  const res = await request.post('/job_salary/export', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}

/**
 * 还款记录
 */
export async function pageRepayRecord(params) {
  params.tenant_id = JSON.stringify(params.tenant_id);
  const res = await request.post('/bill_repay_record/getList', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}

/**
 * 账单列表
 */
export async function pageBill(params) {
  params.tenant_id = JSON.stringify(params.tenant_id);
  const res = await request.post('/bill_detail/getList', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}

/**
 * 企业提现
 */
export async function pageTenantWithdraw(params) {
  const res = await request.post('/tenant_withdraw/getList', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}

/**
 * 企业提现
 */
export async function setTenantWithdrawStatus(params) {
  const res = await request.post('/tenant_withdraw/setStatus', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
